import { NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';

export async function GET() {
  try {
    // 从数据库获取所有用户
    const users = await prisma.user.findMany({
      select: {
        openId: true,
        uName: true,
        avatarUrl: true,
        college: true,
        gender: true,
        birth: true
      }
    });

    return NextResponse.json({ users }, { status: 200 });
  } catch (error) {
    console.error('获取用户数据失败:', error);
    return NextResponse.json(
      { error: '获取用户数据失败' },
      { status: 500 }
    );
  }
}